<?php
namespace app\api\model;


use think\Model;
/**
* 
*/
class Collect extends Model
{
	


	public function add($data){
		$res = self::save($data);
		if($res){
			return_json(200,'成功',true);
		}else{
			return_json(400,'失败',false);

		}

	}

	public function cancel($data){
		$res = db('collect')->where('uid',$data['uid'])->where('goods_id',$data['goods_id'])->delete();
		if($res){
			return_json(200,'成功',true);
		}else{
			return_json(200,'成功',false);

		}

	}
	public function select($uid){

		$res = self::where('uid',$uid)->all();
		if(!empty($res)){
			foreach ($res as $k => $v) {
				$goods[] = db('goods')->field('id,goods_title,title_thumb,goods_price')->where('id',$v['goods_id'])->find();
			}
		
		}
		return_json(200,'成功',$goods);
	}

}
?>